package online.sixfish.doubao.listener;

import online.sixfish.doubao.event.ArticleViewEvent;
import online.sixfish.doubao.event.CoursewareDownloadEvent;
import online.sixfish.doubao.service.ArticleService;
import online.sixfish.doubao.service.CoursewareService;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class CoursewareListener {
    @Resource
    CoursewareService coursewareService;
    private static final int DOWNLOAD_HEAT=10;


    @Async("executor")
    @EventListener
    public void handleArticleViewEvent(CoursewareDownloadEvent event){
        coursewareService.incrementHeat(event.getId(),DOWNLOAD_HEAT);
    }
}